package com.example.qundui.learndemo;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

/**
 * Created by qundui on 2017/4/14.
 */

public class Test extends Activity {
    boolean isselect=false;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);

    }
    public void test(View view){
        final int res[]=new int[]{R.drawable.icon_checked,R.drawable.icon_unchecked};
        AlertDialog.Builder adb=new AlertDialog.Builder(this);
        AlertDialog alertDialog = adb.create();
        alertDialog.show();
        View v= LayoutInflater.from(this).inflate(R.layout.dialog,null);
        final Button ok= (Button) v.findViewById(R.id.btn);
        ok.setBackgroundResource(res[1]);
        ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i("gsc",""+isselect);
                //ok.setBackgroundResource(res[0]);

                isselect=!isselect;
                if (isselect){
                    ok.setBackgroundResource(res[0]);

                }
                else{
                    ok.setBackgroundResource(res[1]);
                }
            }
        });

        alertDialog.setContentView(v);

    }
}
